package com.tg.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.demo.view.SettingItemTextViewEx;
import com.inuker.bluetooth.library.search.SearchResult;
import com.tg.app.R;

import java.util.ArrayList;

public class BluetoothDeviceAdapter extends BaseAdapter {
    private ArrayList<SearchResult> list;

    private Context context;

    public BluetoothDeviceAdapter(ArrayList<SearchResult> list, Context context){
        this.list = list;
        this.context = context;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.layout_lockbell_bluetooth, null);
        }
        SettingItemTextViewEx settingItemTextView = (SettingItemTextViewEx)convertView;
        SearchResult data = list.get(position);
        settingItemTextView.setMark(data.getName());
        return convertView;
    }
}
